package com.sgb.member.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import com.sgb.member.BR;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemMemberApprovalRecordBinding;
import com.sgb.member.entity.ApprovalRecordBean;
import com.sgb.member.entity.MemberAuditBean;
import com.sgb.member.entity.QualityMemberBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.StringUtil;

import java.util.List;

public abstract class MemberApprovalRecordAdapter extends BaseRecycleAdapter<ApprovalRecordBean> {

    private final int mCurPage;

    public MemberApprovalRecordAdapter(Context context, List<ApprovalRecordBean> datas, int curPage) {
        super(context, R.layout.item_member_approval_record, datas);
        mCurPage = curPage;
    }

    @Override
    public void convert(ItemViewHolder holder, final ApprovalRecordBean entity) {
        holder.setBinding(BR.viewModel, entity);
        holder.setBinding(BR.curPage, mCurPage);
        ItemMemberApprovalRecordBinding binding = (ItemMemberApprovalRecordBinding) holder.getmBinding();
        binding.tvInvite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                againInvite(entity);
            }
        });
        // status 状态 1待审批，2审批通过 3，拒绝
        switch (entity.getStatus()) {
            case 1:
                binding.tvInvite.setVisibility(View.GONE);
                binding.ivStatus.setImageResource(R.mipmap.member_approval_await);
                break;
            case 2:
                binding.tvInvite.setVisibility(View.GONE);
                binding.ivStatus.setImageResource(R.mipmap.member_icon_passed);
                break;
            case 3:
                binding.tvInvite.setVisibility(View.VISIBLE);
                binding.ivStatus.setImageResource(R.mipmap.member_icon_yjj);
                binding.tvInvite.setText("重新提交");
                break;
            default:
                binding.tvInvite.setVisibility(View.GONE);
                break;
        }
    }

    protected abstract void againInvite(ApprovalRecordBean entity);

}
